<template>
	<div class="export-dialog-view" v-loading="pageLoading">
		<div class="export-dialog">
			<div class="left-lay">
				<div class="split-title">{{ title }}</div>
				<div class="left-line">
					<div class="line-title">
						{{ $t("message.bhView.leftComponents.device") }}
					</div>
					<div class="line-value">{{ $store.state.btn_set_BHView2 ? $store.state.plantName : '担当課' }}</div>
				</div>

				<div class="left-line" v-if="!$store.state.btn_set_BHView2">
					<div class="line-title">
						課名1
					</div>
					<div class="line-value">{{ this.$store.state.DanDang.SecName1 }}</div>
				</div>

				<div class="left-line" v-if="!$store.state.btn_set_BHView2">
					<div class="line-title">
						課名2
					</div>
					<div class="line-value">{{ this.$store.state.DanDang.SecName2 }}</div>
				</div>

				<div class="left-line" v-if="!$store.state.btn_set_BHView2">
					<div class="line-title">
						課名3
					</div>
					<div class="line-value">{{ this.$store.state.DanDang.SecName3 }}</div>
				</div>

				<div class="left-line">
					<div class="line-title">
						{{ $t("message.bhView.leftComponents.object") }}
					</div>
					<div class="line-value">
						{{
							$store.state.macType == 1
								? $t("message.bhView.leftComponents.machine")
								: $t("message.bhView.leftComponents.piping")
						}}
					</div>
				</div>

				<div class="left-line">
					<div class="line-title">
						{{ $t("message.reportFrom.exportDialog.title_c") }}
					</div>
					<div class="line-value">{{ fileTypeStr }}</div>
				</div>

				<div class="left-draw" id="left-draw"></div>
			</div>

			<div class="tip-lay"></div>

			<div class="right-lay">
				<div class="split-title text-right">
					<i class="el-icon-close" @click="CloseExprotDiloag"></i>
				</div>
				<div class="split-title">
					{{ $t("message.reportFrom.exportDialog.title_l") }}
				</div>
				<div class="right-line">
					<div class="line-title">
						残寿命
					</div>
					<div class="line-content">
						<el-radio-group v-model="Data.LifeType">
							<el-radio :label="1">最終測定基準</el-radio>
							<el-radio :label="2">現在基準</el-radio>
						</el-radio-group>
					</div>
				</div>
				<div class="right-line">
					<div class="line-title">
						検査工事項目
					</div>
					<div class="line-content">
						<el-select v-model="Data.InspForPro" placeholder=" " class="ipt">
							<el-option v-for="(item, index) in ComList.thickInspForPro" :key="item.key"
								:label="item.label" :value="item.key">
							</el-option>
						</el-select>
					</div>
				</div>
				<div class="right-line">
					<div class="line-title">
						検査工事目的
					</div>
					<div class="line-content">
						<el-select v-model="Data.InspForPurpose" placeholder=" " class="ipt">
							<el-option v-for="(item, index) in ComList.inspForPurpose" :key="item.key"
								:label="item.label" :value="item.key">
							</el-option>
						</el-select>
					</div>
				</div>
				<div class="right-line">
					<div class="line-title">
						損傷要因
					</div>
					<div class="line-content">
						<el-select v-model="Data.CauseOfInjury" placeholder=" " class="ipt">
							<el-option v-for="(item, index) in ComList.causeOfInjury" :key="item.key"
								:label="item.label" :value="item.label">
							</el-option>
						</el-select>
					</div>
				</div>
				<div class="right-line">
					<div class="line-title">
						実施年月
					</div>
					<div class="line-content">
						<el-date-picker v-model="Data.ExecFrom" type="month" :format="format" :value-format="format"
							placeholder=" " class="ipt picker orange">
						</el-date-picker>
						<span style="width: 30px;display: inline-block;text-align: center;">~</span>
						<el-date-picker v-model="Data.ExecTo" type="month" :format="format" :value-format="format"
							placeholder=" " class="ipt picker orange">
						</el-date-picker>
					</div>
				</div>
				<div class="right-line">
					<div class="line-title">
						残寿命
					</div>
					<div class="line-content" style="transform: translateX(-53px);">
						<span>From</span>
						<el-input class="ipt picker" v-model="Data.ResidualFrom"
							@input="Data.ResidualFrom = Number($setMyNum(Data.ResidualFrom, '3 - 2')) == 0 ? null : $setMyNum(Data.ResidualFrom, '3 - 2')"></el-input>
						<span style="width: 30px;display: inline-block;text-align: center;">To</span>
						<el-input class="ipt picker" v-model="Data.ResidualTo"
							@input="Data.ResidualTo = Number($setMyNum(Data.ResidualTo, '3 - 2')) == 0 ? null : $setMyNum(Data.ResidualTo, '3 - 2')"></el-input>
					</div>
				</div>
				<div class="right-line">
					<div class="line-title">
						腐食率
					</div>
					<div class="line-content" style="transform: translateX(-53px);">
						<span>From</span>
						<el-input class="ipt picker" v-model="Data.DecayFrom"
							@input="Data.DecayFrom = Number($setMyNum(Data.DecayFrom, '3 - 2')) == 0 ? null : $setMyNum(Data.DecayFrom, '3 - 2')"></el-input>
						<span style="width: 30px;display: inline-block;text-align: center;">To</span>
						<el-input class="ipt picker" v-model="Data.DecayTo"
							@input="Data.DecayTo = Number($setMyNum(Data.DecayTo, '3 - 2')) == 0 ? null : $setMyNum(Data.DecayTo, '3 - 2')"></el-input>
					</div>
				</div>
				<div class="right-line">
					<div class="line-title">
						残寿命·腐食率·絞り込み対象
					</div>
				</div>
				<div class="right-line">
					<div class="line-title">
					</div>
					<div class="line-content">
						<el-checkbox-group v-model="Data.ResidualValueList">
							<el-checkbox :label="0">短期</el-checkbox>
							<el-checkbox :label="1">通年</el-checkbox>
							<el-checkbox :label="2">回帰</el-checkbox>
						</el-checkbox-group>
					</div>
				</div>
				<div class="right-line">
					<div class="line-title">
						漏洩確率表示
					</div>
					<div class="line-content">
						<el-checkbox :disabled="$store.state.macType == 1"
							v-model="Data.ProbabilityFLg">表示する</el-checkbox>
					</div>
				</div>
				<div class="right-line">
					<div class="line-title">
						漏洩確率
					</div>
					<div class="line-content">
						<el-select v-model="Data.Probability1" placeholder=" " class="ipt"
							:disabled="!Data.ProbabilityFLg" style="width: 140px;">
							<el-option v-for="(item, index) in ComList.leakageProbability" :key="index" :label="item"
								:value="item">
							</el-option>
						</el-select>
						<span style="width: 30px;display: inline-block;text-align: center;"></span>
						<el-select v-model="Data.Probability2" placeholder=" " class="ipt"
							:disabled="!Data.ProbabilityFLg" style="width: 140px;">
							<el-option v-for="(item, index) in ComList.leakageAccuracyCond" :key="index"
								:label="item.label" :value="item.key">
							</el-option>
						</el-select>
					</div>
				</div>
				<div class="right-line">
					<div class="line-title">
						改ページ単位
					</div>
					<div class="line-content">
						<el-checkbox v-model="Data.PrintType">{{ $t("message.ReportFormTable.D_C.lab5") }}</el-checkbox>
					</div>
				</div>
			</div>
			<footer class="footer-view">
				<div class="">
					<div class="line-title" style="width: 100%">
						{{ $t("message.reportFrom.exportDialog.tip") }}
					</div>
				</div>
				<div>
					<button @click="CloseExprotDiloag">Cancel</button>
					<button @click="onExportClick">OK</button>
				</div>
			</footer>
		</div>
	</div>
</template>

<script>
import {
	ExCGInspInventoryCombox, ExLifePrediction,
	CollectFiles
} from "@/api/api";
import * as svg_opt from "@/utils/svg_opt.js";
import { getLocalStorage } from "@/utils/storage";
import timeFormat from "@/utils/timeFormat";
export default {
	props: ["title", "fileTypeStr", "selectMacData", "fileRadio"],
	name: "B_B_Export",
	data() {
		return {
			pageLoading: false,
			colorList: [],
			color: '',

			format: 'yyyy-MM',

			ComList: {
				causeOfInjury: [],
				inspForPro: [],
				inspForPurpose: [],
				meishiPeriod: [],
			},
			PrintType: false,
			Data: {
				ProbabilityFLg: false,
				LifeType: 1,
				MacType: this.$store.state.macType,
				ExecFrom: '',
				ExecTo: '',
				InspForPro: 0,
				InspForPurpose: 1,
				CauseOfInjury: '',
				ResidualValueList: [0, 1, 2],
				ResidualFrom: null,
				ResidualTo: null,
				DecayFrom: null,
				DecayTo: null,
				Probability1: 1,
				Probability2: 0,
				PltCode: this.$store.state.pltCode,
				PrintType: true
			},

		};
	},
	components: {},
	watch: {},
	methods: {
		CloseExprotDiloag() {
			this.$emit("CloseExprotDiloag");
		},
		async onExportClick() {
			this.pageLoading = true;

			let DmgCode = this.selectMacData.map(item => item.macCode.toString());
			let dataJson = {
				PltCode: this.selectMacData[0].pltCode,
				MacType: this.selectMacData[0].macType,
				DmgCode,
				...this.Data,
				PrintType: this.Data.PrintType ? 2 : 1
			};
			let res = await ExLifePrediction(dataJson);
			this.pageLoading = false;

			if (res.data.code == -310) {
				this.$alert(res.data.msg, '', {
					confirmButtonText: 'OK',
					type: 'warning',
				});
				return
			} else if (res.data.code != 0) {
				this.$alert(res.data.msg, '', {
					confirmButtonText: 'OK',
					type: 'warning',
				});

			} else if (res.data.code == 0) {
				window.open(res.data.data);
			}
			this.$emit("CloseExprotDiloag");
			return
		},
		// 获取下拉框
		async ExCGInspInventoryComboxFn() {
			this.pageLoading = true;
			let res = await ExCGInspInventoryCombox({});
			setTimeout(() => {
				this.pageLoading = false;
			}, 300);
			this.ComList = res.data.data;
			// this.ComList.Probability1List = [1, 2, 3, 4, 5];
			// this.ComList.Probability2List = ['>=', '<=', '<>'];
			this.ComList.leakageAccuracyCond[0].label = ' ';
			this.Data.Probability1 = this.ComList.leakageProbability[0];
			this.Data.Probability2 = this.ComList.leakageAccuracyCond[0].key;
		},
		// 开始
		async initFn() {
			this.ExCGInspInventoryComboxFn();
		}
	},
	created() {


	},
	mounted() {
		this.initFn();
	},
	beforeDestroy() { },
	destroyed() { },
};
</script>
<style lang="scss" scoped>
.export-dialog-view {
	position: fixed;
	width: 100%;
	height: 100%;
	left: 0;
	top: 0;
	z-index: 6;
}

.export-dialog {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 852px;
	height: 680px;
	// height: 292px;
	background: #ffffff;
	box-shadow: 0px 12px 48px 16px rgba(0, 0, 0, 0.05),
		0px 9px 28px 0px rgba(0, 0, 0, 0.08),
		0px 6px 16px -8px rgba(0, 0, 0, 0.15);
	display: flex;
	flex-direction: row;
	padding: 0 12px;
}

.left-lay {
	position: relative;
	width: 40%;
	height: 100%;
	// border-right: 1px solid #ccc;
	display: flex;
	flex-direction: column;
	// background-color: blanchedalmond;

	.left-line {
		width: 100%;
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 0px 20px;
		padding-top: 10px;

		.line-title {
			font-size: 14px;
			font-weight: 700;
			color: rgba(0, 0, 0, 0.85);
			line-height: 22px;
		}

		.line-value {
			font-size: 14px;
			font-weight: 400;
			color: #7b7b7b;
			line-height: 22px;
			margin-left: 10px;
		}
	}

	.left-draw {
		position: absolute;
		top: 100vh;
		width: 750px;
		height: 611px;
		// flex-grow: 1;
		// flex-shrink: 1;
		background-color: bisque;
	}
}

.tip-lay {
	background: red;
	width: 7px;
	border-radius: 4px;
	background: #ccc;
	margin-top: 46px;
	margin: 46px 15px 85px 15px;
}

.right-lay {
	position: relative;
	width: 65%;
	height: 100%;
	display: flex;
	flex-direction: column;

	.el-icon-close {
		font-size: 16px;
		cursor: pointer;
		width: 46px;
		height: 45px;
		line-height: 45px;
	}

	.right-block-container {
		width: 100%;
		display: flex;
		flex-direction: column;
	}

	.text-right {
		padding: 0 !important;
		text-align: right;
	}

	.right-line {
		width: 100%;
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 0px 12px;
		padding-top: 10px;

		.line-title {
			min-width: 100px;
			font-size: 14px;
			font-weight: 700;
			color: rgba(0, 0, 0, 0.85);
			line-height: 22px;
			text-align: left;
			margin-right: 10px;
		}

		.line-content {
			flex-grow: 1;
			flex-shrink: 1;
			display: flex;
			flex-direction: row;
			align-items: center;
		}

		.ipt {
			//     width: 368px;
			width: 320px;
			height: 32px;

			::v-deep .el-input__inner {
				width: 100% !important;
				height: 32px;
			}

			::v-deep .el-input__inner:focus {
				border: 1px solid #dcdfe6;
			}

			::v-deep .el-input__icon {
				line-height: 32px;
				color: #909399;
			}

			::v-deep .el-input__suffix {
				width: 32px;
				right: 0;
				background: #dee0e3;
			}
		}

		.picker {
			width: 140px;
			// margin: 0px 10px;

			::v-deep .el-input__inner {
				width: 100%;
			}

			::v-deep .el-input__suffix {
				background: transparent;
			}

		}

		span {
			padding: 0 5px;
			margin: 0 5px;
		}

		.divider {
			width: 100%;
			height: 1px;
			background-color: #f0f0f0;
		}
	}

	.right-line.bottom-border {
		padding-bottom: 10px;
		// border-bottom: 1px solid #f0f0f0;
	}

	.flex-row {
		flex-direction: row;
	}

	.flex-column {
		flex-direction: column;
	}
}

.split-title {
	width: 100%;
	font-size: 16px;
	font-weight: 700;
	color: rgba(0, 0, 0, 0.85);
	line-height: 22px;
	padding: 12px 12px;
	border-bottom: 1px solid #f0f0f0;
}

.footer-view {
	width: calc(100% - 30px);
	box-sizing: border-box;
	position: absolute;
	z-index: 10;
	bottom: 16px;
	// padding: 0 15px;
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: space-between;
	// background-color: red;
	padding-top: 17px;
	border-top: 1px solid #f0f0f0;
	font-size: 16px;
	font-weight: 700;

	button {
		width: 82px;
		height: 32px;
		background: #ffffff;
		border: 1px solid #d9d9d9;
		margin-left: 12px;
		border-radius: 4px;
		font-size: 14px;
		font-weight: 500;
	}

	button:nth-child(2) {
		background: #106ebe;
		color: #fff;
	}
}

#right-CAD {
	width: 1207px;
	height: 680px;
	position: fixed;
	top: -200vh;
	left: 0;
	z-index: -999;
}
</style>
